<?php
/**
 * Created by PhpStorm.
 * User: venki
 * Date: 2023/11/18
 * Time: 14:24
 */

namespace app\services;

use app\behaviors\CustomBehavior;
use app\events\CustomEvent;
use yii\base\Component;

class CustomService extends Component
{
    /*public function __construct($config = [])
    {
        parent::__construct($config);

        // 附加行为
        $this->attachBehavior('customBehavior', CustomBehavior::class);
    }*/

    public function someMethod()
    {
        echo 2222222;
        // 创建事件实例并设置需要传递的数据
        $event       = new CustomEvent();
        $event->data = 'Some data to be processed by the behavior';

        // 触发事件
        $this->trigger('customEvent', $event);
        CustomEvent::trigger(CustomEvent::class,'',null);
        echo 1;
        die;
        // 继续执行Service的其他逻辑
    }

    public static function a()
    {
        echo 1111111;
        die;
    }
}